--[[/**
-- * 
 * 每次伤害扣能量
 * 能量不足 每溢出 N点 伤害加深N
-- */]]

---@class BuffEffect375100000 : BaseBuffEffect
BuffEffect375100000 = ClientFight.CreateClass("BuffEffect375100000", ClientFight.BaseBuffEffect)
local t = BuffEffect375100000

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
 if (table.getn(parameters) < 3)then
 return IBuffEffect.FAIL;
 end
 if (not parameters[3])then
 return IBuffEffect.FAIL;
 end
 if (not parameters[1] )then
 return IBuffEffect.FAIL;
 end
 if (not parameters[2])then
 return IBuffEffect.FAIL;
 end
 local result = parameters[3];

 if (not AttackUtils.isDamage(result.state))then
 return IBuffEffect.FAIL;
 end
 local buffEffectValue = buff.buffBean.f_BuffEffectValue;
 local skill = parameters[2];
 local skillTarget =  parameters[1];
 local energy = FighterManager.addEnergy(fight, skillTarget, skill.skill.skillBean.f_skillId, fight.frame, buffEffectValue[1], EnergyChangeReasonEnum.BUFF);
 if (energy >= 0  or not result:isDamage())then--没造成伤害
  SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
 .. buff.modelId .. " 扣除能量: " ..buffEffectValue[1]);
  return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

 end
 energy = math.abs(energy);
 local step = energy / buffEffectValue[2];
 if (step < 0)then
  return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);

 end
 local addDamage = (result.damage * Utils.toRatio(step * buffEffectValue[3]));
 result.damage = addDamage + result.damage;
 local logEnergy = energy;
 SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
         .. buff.modelId .. " 扣除能量: " .. buffEffectValue[1] .. " 溢出:"..logEnergy .."  触发增伤: ".. addDamage);

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()